import React, { Component } from "react";

export default class App extends Component {
  state = {
    text: "收藏",
  };

  /*
    如果你想在constructor中通过this.state = {...}这样的形式去初始化state，务必要先调用super();
    constructor() {
      super();
      this.state = { text: "收藏" };
    }
  */

  render() {
    return (
      <div>
        <h1>{this.state.text}</h1>
        {/* react中规定必须通过setState()去修改state中的状态, 使用方式如下 */}
        <button onClick={() => this.setState({ text: "222" })}>click</button>
      </div>
    );
  }
}
